package starter;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class StartGame extends JFrame{
	/**
	 * Starts the game's main menu
	 */
	private static final long serialVersionUID = 7795318986817740283L;
	private BufferedImage title;
	public static final int windowWidth = 900;
	public static final int windowHeight = 600;
	private StartGame(){

//		//FOR TESTING PURPOSES ONLY
//		gui.StartGUI gui = new gui.StartGUI(windowWidth, windowHeight);
//		gui.setVisible(true);
//		setVisible(false);
//		//FOR TESTING PURPOSES ONLY

		this.setResizable(false);
		this.setSize(windowWidth,windowHeight);
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		this.setLocationRelativeTo(null);

		JPanel mainPanel = new JPanel();
		mainPanel.setBounds(0,0,windowWidth,windowHeight);
		mainPanel.setBackground(Color.BLACK);
		this.add(mainPanel);


		JButton startButton = new JButton("Start Game");
		startButton.setBackground(Color.WHITE);
		startButton.setBounds((windowWidth/2)-(windowWidth/10), (int)(windowHeight*.75), windowWidth/5, 30);
//		startButton.setBounds(0, 0, 100, 30);
		startButton.setOpaque(true);
		startButton.setForeground(Color.BLACK);
//		startButton.setMargin(new Insets(1, 1, 1, 1) );
		startButton.setFocusPainted(false);
		mainPanel.setLayout(null);
		mainPanel.add(startButton);

		try{
			title = ImageIO.read(new File("resources/images/title.png"));
		}catch(Exception e){
			System.out.println("Failed to load image");
		}
		JLabel picLabel = new JLabel(new ImageIcon(title));
		picLabel.setBounds(0, 0, windowWidth, windowHeight);
		mainPanel.add(picLabel);

		startButton.setMnemonic(KeyEvent.VK_ENTER);
		startButton.addMouseListener(new MouseListener() {

			public void mouseReleased(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			public void mousePressed(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			public void mouseExited(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			public void mouseEntered(MouseEvent arg0) {
				// TODO Auto-generated method stub

			}

			public void mouseClicked(MouseEvent arg0) {
				gui.StartGUI gui = new gui.StartGUI(windowWidth, windowHeight);
				gui.setVisible(true);
				setVisible(false);
			}
		});
	}
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				StartGame Starter = new StartGame();
				Starter.setVisible(true);
			}
		});
	}
}
